/*    
    LogParser - Log File Parser Unit Tests
    Copyright (C) 2007  Alois Kraus
  
    This source code is published under the Microsoft Permissive License (Ms-PL)
    http://www.microsoft.com/resources/sharedsource/licensingbasics/permissivelicense.mspx
*/


using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
#endif


namespace EntLibContrib.Logging.UnitTests.Parser
{
    [TestClass]
    public class TestDataGenerator
    {
        const string Msg = "Hello world";
        #if DEBUG
        public const int TotalMessages = 10;  // faster debugging
        #else
        public const int TotalMessages = 10000;
        #endif

        [TestMethod]
        //[Explicit]
        #if !NUNIT
        [DeploymentItem("loggingtest.config")]
        #endif
        public void WriteLogData()
        {
            CultureInfo ciRestore = System.Threading.Thread.CurrentThread.CurrentCulture;
            CultureInfo ciTesting = new CultureInfo("de-DE");
            System.Threading.Thread.CurrentThread.CurrentCulture = ciTesting;

            LogWriterFactory factory = new LogWriterFactory(new FileConfigurationSource(ConfigReaderTests.SampleConfigFile));
            LogWriter writer = factory.Create();
            LogEntry entry = new LogEntry();
            for (int i = 1; i < TotalMessages; i++)
            {
                entry.Message = Msg + i;
                writer.Write(entry);
            }
            writer.Dispose();

            System.Threading.Thread.CurrentThread.CurrentCulture = ciRestore;
        }
    }
}
